/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.moto.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author munhofi
 */
@Entity
@Table(name = "recado")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Recado.findAll", query = "SELECT r FROM Recado r"),
    @NamedQuery(name = "Recado.findById", query = "SELECT r FROM Recado r WHERE r.id = :id"),
    @NamedQuery(name = "Recado.findByUsername", query = "SELECT r FROM Recado r WHERE r.idPessoaPara.email = :username"),
    @NamedQuery(name = "Recado.findByDataCadastro", query = "SELECT r FROM Recado r WHERE r.dataCadastro = :dataCadastro")})
public class Recado implements Serializable {
    @Column(name = "data_cadastro")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dataCadastro;
    @OneToMany(mappedBy = "idRecado")
    private List<Comentario> comentarioList;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Integer id;
    @Lob
    @Size(max = 65535)
    @Column(name = "recado")
    private String recado;
    @JoinColumn(name = "id_pessoa_para", referencedColumnName = "id")
    @ManyToOne
    private Pessoa idPessoaPara;
    @JoinColumn(name = "id_pessoa_de", referencedColumnName = "id")
    @ManyToOne
    private Pessoa idPessoaDe;

    public Recado() {
    }

    public Recado(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getDataCadastro() {
        return dataCadastro;
    }

    public void setDataCadastro(Date dataCadastro) {
        this.dataCadastro = dataCadastro;
    }

    public String getRecado() {
        return recado;
    }

    public void setRecado(String recado) {
        this.recado = recado;
    }

    public Pessoa getIdPessoaPara() {
        return idPessoaPara;
    }

    public void setIdPessoaPara(Pessoa idPessoaPara) {
        this.idPessoaPara = idPessoaPara;
    }

    public Pessoa getIdPessoaDe() {
        return idPessoaDe;
    }

    public void setIdPessoaDe(Pessoa idPessoaDe) {
        this.idPessoaDe = idPessoaDe;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Recado)) {
            return false;
        }
        Recado other = (Recado) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.com.moto.entity.Recado[ id=" + id + " ]";
    }
 
    @XmlTransient
    public List<Comentario> getComentarioList() {
        return comentarioList;
    }

    public void setComentarioList(List<Comentario> comentarioList) {
        this.comentarioList = comentarioList;
    }
    
}
